﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace NNDC
{
    public partial class Pwd : Form
    {
        public Pwd()
        {
            InitializeComponent();
        }
        public string names;
        private void Pwd_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtpwd1.Text == "")
            {
                MessageBox.Show("请输入新密码");
                txtpwd1.Focus();
            }
            else
            {
                if (txtpwd2.Text != txtpwd1.Text)
                {
                    MessageBox.Show("两次密码不一致");
                    txtpwd2.Focus();
                }
                else
                {
                    SqlConnection conn = data.DBConn.Cycon();
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("update tb_User set UserPwd='"+txtpwd1.Text+"' where UserName='"+names+"'",conn);
                    cmd.ExecuteNonQuery();
                    if (MessageBox.Show("密码修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) == DialogResult.OK)
                    {
                        this.Close();
                    }

                }
            }
        }
    }
}
